﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Konstaller
{
    public class ProgressBar
    {

        /// <summary>
        /// Private Field
        /// </summary>
        private int vl = 0;
        private string txt = "Progress Bar:";


        /// <summary>
        /// Get or Set Value of ProgressBar
        /// </summary>
        public int Value
        {
            get { return vl; }
            set { vl = value; }
        }


        /// <summary>
        /// Get or Set Text of ProgressaBar
        /// </summary>
        public string Text
        {
            get { return txt; }
            set { txt = value; }
        }



        /// <summary>
        /// Draw Method
        /// </summary>
        /// <param name="x">Set X Position</param>
        /// <param name="y">Set Y Position</param>
        public void Draw(int x, int y)
        {

            Console.SetCursorPosition(x, y);
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write(Text + " ");
            Console.BackgroundColor = ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.White;


            //Prevenzione superamento del valore
            if (Value > 100) { Value = 100; }


            if (Value == 0) { Console.Write("          "); }
            if (Value >= 0 && Value <= 19) 
            { 
                Console.BackgroundColor = ConsoleColor.DarkGreen; 
                Console.ForegroundColor = ConsoleColor.DarkGreen; 
                Console.Write(" ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("         ");
            }

            if (Value >= 20 && Value <= 29)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("  ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("        ");
            }

            if (Value >= 30 && Value <= 39)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("   ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("       ");
            }

            if (Value >= 40 && Value <= 49)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("    ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("      ");
            }

            if (Value >= 50 && Value <= 59)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("     ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("     ");
            }

            if (Value >= 60 && Value <= 69)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("      ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("    ");
            }

            if (Value >= 70 && Value <= 79)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("       ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("   ");
            }

            if (Value >= 80 && Value <= 89)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("        ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("  ");
            }

            if (Value >= 90 && Value <= 99)
            {
                Console.BackgroundColor = ConsoleColor.DarkGreen;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Write("         ");
                Console.BackgroundColor = ConsoleColor.Black;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(" ");
            }

            if (Value == 100)
            {
               
                    Console.BackgroundColor = ConsoleColor.DarkGreen;
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.Write("          ");
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("");
                
            }

            Console.BackgroundColor = ConsoleColor.Blue;
            Console.ForegroundColor = ConsoleColor.White;

            Console.Write(" " + Value + " %");
        }

    }
}
